package com.yixun.qfbao.model.enums;

import com.yixun.common.utils.StringUtil;
import com.yixun.qfbao.util.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

public enum DateToEnum {
	DATE_TT("0","所有",null),
	DATE_3("3","最近3天",DateToEnum.dateFomart(DateUtils.getPreDate(new Date(), -3))),
	DATE_7("7","最近7天",DateToEnum.dateFomart(DateUtils.getPreDate(new Date(), -7))),
	DATE_30("30","最近30天",DateToEnum.dateFomart(DateUtils.getPreDate(new Date(), -30)));
	private String no;
	private String des;
	private String toDate;
	public String getNo() {
		return no;
	}
	public void setNo(String no) {
		this.no = no;
	}

	public String getDes() {
		return des;
	}

	public void setDes(String des) {
		this.des = des;
	}


	

	private DateToEnum(String no, String des, String toDate) {
		this.no = no;
		this.des = des;
		this.toDate = toDate;
	}
	public String getToDate() {
		return toDate;
	}
	public void setToDate(String toDate) {
		this.toDate = toDate;
	}
	public static DateToEnum getByNo(String no) {
		if (StringUtil.isEmpty(no)) {
			return null;
		}
		for (DateToEnum menum : values()) {
			if (menum.getNo().equals(no)) {
				return menum;
			}
		}
		return null;
	}
	
	public static String dateFomart(Date date){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		return df.format(date);
	}

}
